package com.yeyks.task;

import com.yeyks.search.constants.EsIndexConstant;
import com.yeyks.search.service.hotel.EsImportHotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时删除房态为空的房间
 *
 * @author: dagny
 * @date: 2019/12/5 0005 10:02
 */
@Component
@Slf4j
public class EsDelRoomAndHotelTask {

    @Autowired
    private EsImportHotelService esImportHotelService;

    /*@Scheduled(cron = "${schedule.room.delData}")*/
    public void delRoomAndHotel(){

        log.info("开始执行删除房间");

        Boolean cn = esImportHotelService.delRoomByCalendarIsNull(EsIndexConstant.INDEX_HOTEL2, "cn", 500, 1);
        if(cn){
            log.info("开始执行删除酒店");
            Boolean cn1 = esImportHotelService.delHotelByRoomIsNull(EsIndexConstant.INDEX_HOTEL2, "cn", 250, 1);
            if(cn1){
                log.info("===========删除操作完成========");
            }
        }
    }
}
